﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for FleetCompanyDB
/// </summary>
namespace CE.CarInsurance
{
    public class FleetCompanyDB
    {
        public Int64 Insert(FleetCompany fleetcompany)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocCXCRMFleetCompanyInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@CompanyId", fleetcompany.CompanyId);
            _sPara.Add("@CompanyName", fleetcompany.CompanyName);
            _sPara.Add("@ContactPerson", fleetcompany.ContactPerson);
            _sPara.Add("@CompanyAddress", fleetcompany.CompanyAddress);
            _sPara.Add("@SubDistrict", fleetcompany.SubDistrict);
            _sPara.Add("@District", fleetcompany.District);
            _sPara.Add("@Province", fleetcompany.Province);
            _sPara.Add("@PostalCode", fleetcompany.PostalCode);
            _sPara.Add("@ContactNo1", fleetcompany.ContactNo1);
            _sPara.Add("@ContactNo2", fleetcompany.ContactNo2);
            _sPara.Add("@Email", fleetcompany.Email);
            _sPara.Add("@AgentId", fleetcompany.AgentId);
            _sPara.Add("@AdminId", fleetcompany.AdminId);
            _sPara.Add("@RefCEUserId", fleetcompany.RefCEUserId);
            _sPara.Add("@Status", fleetcompany.Status);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public Int64 Delete(Int64 CompanyId, Int64 RefCEUserId)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocCXCRMFleetCompanyDeleteSingleItem";

            SortedList _sPara = new SortedList();
            _sPara.Add("@CompanyId", CompanyId);
            _sPara.Add("@RefCEUserId", RefCEUserId);

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataSet GetFleetCompany(Int64 CompanyId, string SearchKey)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "sprocCXCRCRMFleetCompanySelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@CompanyId", CompanyId);
            _spara.Add("@SearchKey", SearchKey);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetFleetCompany(Int64 CompanyId)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "sprocCXCRCRMFleetCompanySelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@CompanyId", CompanyId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetFleetCompany(string SearchKey)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "sprocCXCRCRMFleetCompanySelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@SearchKey", SearchKey);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetFleetCompany()
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "sprocCXCRCRMFleetCompanySelectItemList";


            DataSet _ds = _db.GetDataSet(_spName);

            return _ds;
        }

    }
}